﻿<UserControl x:Class="TrixPlugin.Historical.ControlPanel"
   
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
			 mc:Ignorable="d"
			 
             xmlns:Converters="clr-namespace:Utils.Wpf.Converters;assembly=Utils"
             xmlns:UserControls="clr-namespace:Plugins.UserControls;assembly=Plugins"
             xmlns:Utils="clr-namespace:Utils.Wpf;assembly=Utils" 
			 xmlns:Trix="clr-namespace:TrixPlugin.Historical" 
			 xmlns:TrixCommon="clr-namespace:TrixPlugin.Common"
			 
             d:DataContext="{d:DesignInstance Type=Trix:ControlPanelVM}"
			 
			 Utils:AnimatorOnVisibilityChange.AnimationType="Fade"
			 Utils:AnimatorOnVisibilityChange.Duration="1000"
			 Visibility="Collapsed"
			 Background="#1F1F1F" >

	<UserControl.Resources>
		<ResourceDictionary>
			<Converters:BooleanNotConverter x:Key="BooleanNotConverter" />
			<Converters:NegatedBooleanToVisibilityConverter x:Key="NegatedBooleanToVisibilityConverter" />
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="pack://application:,,,/Plugins;component/PluginTheme.xaml" />
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</UserControl.Resources>

	<UserControl.IsEnabled>
		<Binding Path="IsBusy" Converter="{StaticResource BooleanNotConverter}" />
	</UserControl.IsEnabled>

	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*" />
		</Grid.ColumnDefinitions>

		<Border Grid.Row="0" BorderThickness="1,1,1,0" BorderBrush="{StaticResource ControlPanelLines}" CornerRadius="10,10,0,0" Background="#DCDCDC" >
			<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" >
				<TextBlock Grid.Row="0" Text="Momentum Strategy Historical Plugin" Margin="3" Foreground="Black" FontWeight="Bold" />
				<Image Source="pack://application:,,,/Plugins;component/Resources/Info.ico" Margin="10,0,0,0" >
					<Image.ToolTip>
						<StackPanel>
							<TextBlock Foreground="Black" FontWeight="Bold" Text="Momentum Historical Plugin" />
							<TextBlock Foreground="Black" >
								The idea is to high speed and high value movements and try to join the movement.<LineBreak/>
							</TextBlock>
						</StackPanel>
					</Image.ToolTip>
					<Image.Style>
						<Style>
							<Style.Triggers>
								<Trigger Property="Image.IsEnabled" Value="False" >
									<Setter Property="Image.Opacity" Value="0.5" />
								</Trigger>
							</Style.Triggers>
						</Style>
					</Image.Style>
				</Image>
			</StackPanel>
		</Border>
		<Border Grid.Row="1" BorderThickness="1" BorderBrush="{StaticResource ControlPanelLines}" Padding="6" CornerRadius="0,0,10,10" >
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="*" />
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="Auto" />
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>

				<!-- Preset Selector -->
				<Expander Grid.Column="0" IsExpanded="True" ExpandDirection="Left" >
					<Expander.Header>
						<ItemsControl TextElement.FontSize="11" ItemsSource="Presets" Foreground="{StaticResource FontBrush}" Visibility="{Binding IsExpanded, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Expander}, AncestorLevel=1}, Converter={StaticResource NegatedBooleanToVisibilityConverter}}" />
					</Expander.Header>
					<UserControls:PresetSelector DataContext="{Binding PresetSelectorVM}" IsSaveEnabled="{Binding IsEnabled, ElementName=ExecuteButton}" />
				</Expander>

				<!-- Separator -->
				<Border Grid.Column="1" BorderBrush="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />

				<!-- Stock Selection -->
				<Expander Grid.Column="2" IsExpanded="True" ExpandDirection="Left" >
					<Expander.Header>
						<ItemsControl TextElement.FontSize="11" ItemsSource="Stocks" Foreground="{StaticResource FontBrush}" Visibility="{Binding IsExpanded, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Expander}, AncestorLevel=1}, Converter={StaticResource NegatedBooleanToVisibilityConverter}}" />
					</Expander.Header>
					<UserControls:StockSelector DataContext="{Binding StockSelectorVM}" />
				</Expander>

				<!-- Separator -->
				<Border Grid.Column="3" BorderBrush="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />

				<!-- Date Selection -->
				<Expander Grid.Column="4" IsExpanded="True" ExpandDirection="Left" >
					<Expander.Header>
						<ItemsControl TextElement.FontSize="11" ItemsSource="Dates" Foreground="{StaticResource FontBrush}" Visibility="{Binding IsExpanded, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Expander}, AncestorLevel=1}, Converter={StaticResource NegatedBooleanToVisibilityConverter}}" />
					</Expander.Header>
					<ContentControl IsEnabled="{Binding StockSelectorVM.IsStockSelected}" >
						<UserControls:DateSelector DataContext="{Binding DateSelectorVM}" />
					</ContentControl>
				</Expander>

				<!-- Separator -->
				<Border Grid.Row="0" Grid.Column="5" BorderBrush="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />

				<!-- Hour Limits -->
				<Expander Grid.Column="6" IsExpanded="True" ExpandDirection="Left" >
					<Expander.Header>
						<ItemsControl TextElement.FontSize="11" ItemsSource="Hours" Foreground="{StaticResource FontBrush}" Visibility="{Binding IsExpanded, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Expander}, AncestorLevel=1}, Converter={StaticResource NegatedBooleanToVisibilityConverter}}" />
					</Expander.Header>
					<ContentControl IsEnabled="{Binding StockSelectorVM.IsStockSelected}" >
						<UserControls:HourSelector DataContext="{Binding HourSelectorVM}"/>
					</ContentControl>
				</Expander>

				<!-- Separator -->
				<Border Grid.Column="7" BorderBrush="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />

				<!-- Stock Parameters -->
				<Expander Grid.Column="8" IsExpanded="True" ExpandDirection="Left" >
					<Expander.Header>
						<ItemsControl TextElement.FontSize="11" ItemsSource="Fees" Foreground="{StaticResource FontBrush}" Visibility="{Binding IsExpanded, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Expander}, AncestorLevel=1}, Converter={StaticResource NegatedBooleanToVisibilityConverter}}" />
					</Expander.Header>
					<ContentControl IsEnabled="{Binding StockSelectorVM.IsStockSelected}" >
						<UserControls:StockParametersSelector DataContext="{Binding StockParametersSelectorVM}"/>
					</ContentControl>
				</Expander>

				<!-- Separator -->
				<Border Grid.Row="0" Grid.Column="9" BorderBrush="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />

				<!-- Parameters -->
				<Expander Grid.Column="10" IsExpanded="True" ExpandDirection="Left" >
					<Expander.Header>
						<ItemsControl TextElement.FontSize="11" ItemsSource="Options" Foreground="{StaticResource FontBrush}" Visibility="{Binding IsExpanded, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Expander}, AncestorLevel=1}, Converter={StaticResource NegatedBooleanToVisibilityConverter}}" />
					</Expander.Header>
					<ContentControl IsEnabled="{Binding StockSelectorVM.IsStockSelected}" >
						<TrixCommon:StrategyControl DataContext="{Binding StrategyControlVM}"/>
					</ContentControl>
				</Expander>

				<!-- Separator -->
				<Border Grid.Row="0" Grid.Column="12" BorderBrush="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />

				<!-- Go Button -->
				<Button Grid.Row="0" Grid.Column="13" Command="{Binding RunStrategyCommand}" x:Name="ExecuteButton" >
					<Button.Style>
						<Style>
							<Style.Triggers>
								<Trigger Property="Button.IsEnabled" Value="False" >
									<Setter Property="Button.Opacity" Value="0.5" />
								</Trigger>
							</Style.Triggers>
						</Style>
					</Button.Style>
					<Image Source="pack://application:,,,/Plugins;component/Resources/Execute.ico" />
					<Button.ToolTip>
						<StackPanel>
							<TextBlock Foreground="Black" FontWeight="Bold" Text="Exectute" />
							<TextBlock Foreground="Black" Text="Execute the current strategy with the selected parameters" />
						</StackPanel>
					</Button.ToolTip>
				</Button>
				<TextBlock Grid.Row="0" Grid.Column="13" Text="{Binding ProgressText, TargetNullValue=0/0, FallbackValue=0/0, NotifyOnTargetUpdated=True, Mode=OneWay}" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="Black" Margin="0,0,0,3" FontWeight="DemiBold" >
					<TextBlock.Style>
						<Style TargetType="TextBlock" >
							<Style.Triggers>
								<EventTrigger RoutedEvent="Binding.TargetUpdated">
									<BeginStoryboard>
										<Storyboard>
											<ColorAnimation AutoReverse="True" From="Black" To="Red" Duration="0:0:0.200" Storyboard.TargetProperty="Foreground.Color" FillBehavior="Stop" />
										</Storyboard>
									</BeginStoryboard>
								</EventTrigger>
							</Style.Triggers>
						</Style>
					</TextBlock.Style>
				</TextBlock>
			</Grid>
		</Border>
	</Grid>
</UserControl>
